export function wxloading() {
    $('<div id="loadingbg"><div id="loading" class="loadingbox"><img src="./images/loading.gif" class="loading"></div><p id="loadingtxt"></p></div>').prependTo('body');

    console.log('wxloading');
    var servePath = "";
    var basePath = servePath + "./images/";
    var loader = new WxMoment.Loader();
    var fileList = ["index1bg.jpg","orientlayer.png","loading.gif","bgm.mp3"];
    for (var i = 0; i < fileList.length; i++) {
        loader.addImage(basePath + fileList[i]);
    }
    loader.addProgressListener(function (e) {//加载过程中的回调
        var percent = Math.round((e.completedCount / e.totalCount) * 100);
        $(document).find("#loadingbg").show();
        $(document).find('#loadingtxt').html(percent + '%');
        windowWH();
    });
    loader.addCompletionListener(function () {//加载素材完毕后的回调
        $(document).find("#loadingbg").hide();
        $("#content, #index1").show();
        //require("./bgm").bgm();//如果H5有背景音乐，直接打开这一行即可
    });
    loader.start();
}


export function windowWH() {
    var ww = $(window).width();
	var wh = $(window).height();
	var bghei = 1624;
	var autohei = 1100;
	var ftop = (wh - autohei) / 2;
	var bgauto1 = -(bghei - wh) / 2;
	var bgauto2 = -(bghei - autohei) / 2;

	if (ww < wh && wh >= autohei) {
		$(".bgimg").css("top", bgauto1);
		$("#content, .onepage").css("height", wh); //这里设置页面里需要跟屏幕高度保持一致的元素
	} else if (ww < wh && wh < autohei) {
		$(".bgimg").css("top", bgauto2);
		$("#content, .onepage").css({height: autohei + "px"});
	}
};
